package se.jocke.nbrs.ui.node;

import javax.swing.Action;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.util.lookup.Lookups;
import se.jocke.nbrs.model.RestServiceGroup;
import se.jocke.nbrs.ui.action.AddNewRestServiceAction;
import se.jocke.nbrs.ui.action.AddNewRestServiceGroupAction;

/**
 *
 * @author jocke
 */
public final class RSGroupNode extends AbstractNode {

    private final RestServiceGroup group;

    public RSGroupNode(RestServiceGroup group) throws IllegalStateException {
        super(Children.create(new RSNodeChildFactory(group.getServicesAsList()), true), Lookups.singleton(group));
        this.group = group;
        this.setDisplayName(group.getName());
        this.setIconBaseWithExtension("/se/jocke/nbrs/ui/rest-groups.png");
    }

    public RestServiceGroup getGroup() {
        return group;
    }
    
    
    @Override
    public Action[] getActions(boolean context) {
        return new Action[]{new AddNewRestServiceAction()};
    }

}
